css: Add generic support for 'inherit' and 'initial'
authorBenjamin Otte <otte@redhat.com>
Thu, 29 Dec 2011 15:18:12 +0000 (16:18 +0100)
committerBenjamin Otte <otte@redhat.com>
Mon, 9 Jan 2012 17:37:51 +0000 (18:37 +0100)
CSS3 says they work for every property, so here we go.

gtk/gtkcssprovider.c
gtk/gtkcsstypesprivate.h
gtk/gtkstyleproperty.c

index 4aa4429665d9219cfdde4e11ae5559c3805213c8..e3fc75ac89c7aaae1c9045a7886de1882615e89b 100644 (file)
@@ -1533,6 +1533,10 @@ gtk_css_style_provider_lookup (GtkStyleProviderPrivate *provider,
       if (ruleset->style == NULL)
         continue;
 
+      if (!_gtk_bitmask_intersects (_gtk_css_lookup_get_missing (lookup),
+                                    ruleset->set_styles))
+        continue;
+
       if (!gtk_css_ruleset_matches (ruleset, path, state))
         continue;
 
index c0c884861a1b45d4e0daaad3c4268e5deaf0b2c6..ff1a844f2d6c351563ac33283edc48c107604ade 100644 (file)
@@ -27,7 +27,7 @@ G_BEGIN_DECLS
 typedef enum {
   GTK_CSS_INHERIT,
   GTK_CSS_INITIAL,
-  GTK_CSS_CURRENT_COLOR
+  GTK_CSS_CURRENT_COLOR /*< nick=currentColor >*/
 } GtkCssSpecialValue;
 
 typedef enum {
index 5eade848a04f25dce25e82853421c1406f414a4a..81f1cfda027c73233dada80988de9877b16d8ef7 100644 (file)
@@ -2326,7 +2326,30 @@ _gtk_style_property_parse_value (const GtkStyleProperty *property,
 
   if (property)
     {
-      if (_gtk_css_parser_try (parser, "none", TRUE))
+      if (_gtk_css_parser_try (parser, "initial", TRUE))
+        {
+          /* the initial value can be explicitly specified with the
+           * ‘initial’ keyword which all properties accept.
+           */
+          g_value_unset (value);
+          g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE);
+          g_value_set_enum (value, GTK_CSS_INITIAL);
+          return TRUE;
+        }
+      else if (_gtk_css_parser_try (parser, "inherit", TRUE))
+        {
+          /* All properties accept the ‘inherit’ value which
+           * explicitly specifies that the value will be determined
+           * by inheritance. The ‘inherit’ value can be used to
+           * strengthen inherited values in the cascade, and it can
+           * also be used on properties that are not normally inherited.
+           */
+          g_value_unset (value);
+          g_value_init (value, GTK_TYPE_CSS_SPECIAL_VALUE);
+          g_value_set_enum (value, GTK_CSS_INHERIT);
+          return TRUE;
+        }
+      else if (_gtk_css_parser_try (parser, "none", TRUE))
         {
           /* Insert the default value, so it has an opportunity
            * to override other style providers when merged
@@ -2383,7 +2406,9 @@ _gtk_style_property_print_value (const GtkStyleProperty *property,
 
   css_string_funcs_init ();
 
-  if (property)
+  if (G_VALUE_HOLDS (value, GTK_TYPE_CSS_SPECIAL_VALUE))
+    func = enum_value_print;
+  else if (property)
     func = property->print_func;
   else
     func = NULL;